import * as Router from 'koa-router';
import { IRouterContext } from '../core/IRouterContext';
import menuService from '../service/SysMenuService';
let sysMenuCtr = new Router();
sysMenuCtr.prefix('/api/menu')

/**
 * 获取菜单列表
 */
sysMenuCtr.post('/menu_list', async (ctx: IRouterContext, next: any) => {
    let menu = await menuService.menuList();
    ctx.status = 200;
    ctx.body = menu;
    await next()
})

/**
 * 二级菜单
 */
sysMenuCtr.post('/menu_two_list', async (ctx: IRouterContext, next: any) => {
    let second = ctx.request.body.nId;
    let menu = await menuService.menu_two_list(second);
    ctx.status = 200;
    ctx.body = menu;
    await next()
})

/**
 * 添加菜单
 */
sysMenuCtr.get('/create_menu', async (ctx: IRouterContext, next: any) => {
    console.log('进入添加菜单__________________',);
    let result_ :any = ctx.request.body;
    let menu = await menuService.createMenu(result_);
    ctx.status = 200;
    ctx.body = menu;
    await next()
})

export default sysMenuCtr;